package com.ruoyi.model.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.model.domain.vo.ModelTaskProcessParamVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.model.domain.ModelTaskProcessParam;
import com.ruoyi.model.service.IModelTaskProcessParamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务处理参数Controller
 *
 * @author rww
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/model/process_param")
public class ModelTaskProcessParamController extends BaseController
{
    @Autowired
    private IModelTaskProcessParamService modelTaskProcessParamService;

    /**
     * 查询任务处理参数列表
     */
    @PreAuthorize("@ss.hasPermi('model:process_param:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelTaskProcessParam modelTaskProcessParam)
    {
        startPage();
        List<ModelTaskProcessParamVo> list = modelTaskProcessParamService.selectModelTaskProcessParamList(modelTaskProcessParam);
        return getDataTable(list);
    }

    /**
     * 导出任务处理参数列表
     */
    @PreAuthorize("@ss.hasPermi('model:process_param:export')")
    @Log(title = "任务处理参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelTaskProcessParam modelTaskProcessParam)
    {
        List<ModelTaskProcessParamVo> list = modelTaskProcessParamService.selectModelTaskProcessParamList(modelTaskProcessParam);
        ExcelUtil<ModelTaskProcessParamVo> util = new ExcelUtil<ModelTaskProcessParamVo>(ModelTaskProcessParamVo.class);
        util.exportExcel(response, list, "任务处理参数数据");
    }

    /**
     * 获取任务处理参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:process_param:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(modelTaskProcessParamService.selectModelTaskProcessParamById(id));
    }

    /**
     * 新增任务处理参数
     */
    @PreAuthorize("@ss.hasPermi('model:process_param:add')")
    @Log(title = "任务处理参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelTaskProcessParam modelTaskProcessParam)
    {
        return toAjax(modelTaskProcessParamService.insertModelTaskProcessParam(modelTaskProcessParam));
    }

    /**
     * 修改任务处理参数
     */
    @PreAuthorize("@ss.hasPermi('model:process_param:edit')")
    @Log(title = "任务处理参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelTaskProcessParam modelTaskProcessParam)
    {
        return toAjax(modelTaskProcessParamService.updateModelTaskProcessParam(modelTaskProcessParam));
    }

    /**
     * 删除任务处理参数
     */
    @PreAuthorize("@ss.hasPermi('model:process_param:remove')")
    @Log(title = "任务处理参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(modelTaskProcessParamService.deleteModelTaskProcessParamByIds(ids));
    }
}
